package com.kelaite.procurement.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity(name = "t_purchase_order")
public class TPurchaseOrder extends TBaseEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private Long id;

	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "company_id")
	private TCompany tCompany; // companyType是client

	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "vendor_id")
	private TVendor tVendor;

	@Column(name = "purchase_order_no", nullable = false, length = 50)
	private String purchaseOrderNo; // 甲方的采购订单号

	@Column(name = "purchase_order_desc")
	private String purchaseOrderDesc;

	@Column(name = "internal_purchase_order_no", nullable = false, length = 50)
	private String internalPurchaseOrderNo; // 内部的采购订单号，由合同创建人手动从页面输入

	@Column(name = "start_time")
	private Date startTime;

	@Column(name = "expired_time")
	private Date expiredTime;

	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "user_id")
	private TUser tUser;

	@Column(name = "currency")
	private short currency;

	@Column(name = "price", nullable = false)
	private Float price;

	@Column(name = "order_status")
	private Short orderStatus;

	@Column(name = "deliver_address")
	private String deliverAddress;

	@Column(name = "sales_order_no", length = 40)
	private String salesOrderNo; // 乙方的销售订单号（可空）

	@Column(name = "evaluation_desc_1")
	private String evaluationDesc1;

	@Column(name = "evaluation_score_1")
	private Double evaluationScore1;

	@Column(name = "evaluation_desc_2")
	private String evaluationDesc2;

	@Column(name = "evaluation_score_2")
	private Double evaluationScore2;

	@Column(name = "evaluation_desc_3")
	private String evaluationDesc3;

	@Column(name = "evaluation_score_3")
	private Double evaluationScore3;

	@Column(name = "evaluation_desc_4")
	private String evaluationDesc4;

	@Column(name = "evaluation_score_4")
	private Double evaluationScore4;

	@Column(name = "evaluation_desc_5")
	private String evaluationDesc5;

	@Column(name = "evaluation_score_5")
	private Double evaluationScore5;

	@Column(name = "evaluation_total_desc")
	private String evaluationTotalDesc;

	@Column(name = "evaluation_total_score")
	private Double evaluationTotalScore;

	@Column(name = "evaluated_by")
	private String evaluatedBy;

	@Column(name = "evaluation_time")
	private Date evaluationTime;

	@Column(name = "gmt_create_time")
	private Date gmtCreateTime;

	@Column(name = "gmt_update_time")
	private Date gmtUpdateTime;

	@Column(name = "created_by")
	private String createdBy;

	@Column(name = "updated_by")
	private String updatedBy;

	@Column(name = "is_delete")
	private boolean isDelete;

	@OneToMany(mappedBy = "tPurchaseOrder", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@OrderBy(value = "id ASC")
	@JsonIgnore
	private Set<TPurchaseOrderItems> tPurchaseOrderItems = new HashSet<TPurchaseOrderItems>();

	@OneToMany(mappedBy = "tPurchaseOrder", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@OrderBy(value = "id ASC")
	@JsonIgnore
	private Set<TPurchaseOrderExecution> tPurchaseOrderExecutions = new HashSet<TPurchaseOrderExecution>();

	@OneToMany(mappedBy = "tPurchaseOrder", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@OrderBy(value = "id ASC")
	@JsonIgnore
	private Set<TPurchaseOrderPayment> tPurchaseOrderPayment = new HashSet<TPurchaseOrderPayment>();

	public TPurchaseOrder() {
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public TCompany gettCompany() {
		return tCompany;
	}

	public void settCompany(TCompany tCompany) {
		this.tCompany = tCompany;
	}

	public TVendor gettVendor() {
		return tVendor;
	}

	public void settVendor(TVendor tVendor) {
		this.tVendor = tVendor;
	}

	public String getPurchaseOrderNo() {
		return purchaseOrderNo;
	}

	public void setPurchaseOrderNo(String purchaseOrderNo) {
		this.purchaseOrderNo = purchaseOrderNo;
	}

	public String getPurchaseOrderDesc() {
		return purchaseOrderDesc;
	}

	public void setPurchaseOrderDesc(String purchaseOrderDesc) {
		this.purchaseOrderDesc = purchaseOrderDesc;
	}

	public String getInternalPurchaseOrderNo() {
		return internalPurchaseOrderNo;
	}

	public void setInternalPurchaseOrderNo(String internalPurchaseOrderNo) {
		this.internalPurchaseOrderNo = internalPurchaseOrderNo;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getExpiredTime() {
		return expiredTime;
	}

	public void setExpiredTime(Date expiredTime) {
		this.expiredTime = expiredTime;
	}

	public TUser gettUser() {
		return tUser;
	}

	public void settUser(TUser tUser) {
		this.tUser = tUser;
	}

	public short getCurrency() {
		return currency;
	}

	public void setCurrency(short currency) {
		this.currency = currency;
	}

	public Float getPrice() {
		return price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	public Short getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(Short orderStatus) {
		this.orderStatus = orderStatus;
	}

	public String getDeliverAddress() {
		return deliverAddress;
	}

	public void setDeliverAddress(String deliverAddress) {
		this.deliverAddress = deliverAddress;
	}

	public String getSalesOrderNo() {
		return salesOrderNo;
	}

	public void setSalesOrderNo(String salesOrderNo) {
		this.salesOrderNo = salesOrderNo;
	}

	public String getEvaluationDesc1() {
		return evaluationDesc1;
	}

	public void setEvaluationDesc1(String evaluationDesc1) {
		this.evaluationDesc1 = evaluationDesc1;
	}

	public Double getEvaluationScore1() {
		return evaluationScore1;
	}

	public void setEvaluationScore1(Double evaluationScore1) {
		this.evaluationScore1 = evaluationScore1;
	}

	public String getEvaluationDesc2() {
		return evaluationDesc2;
	}

	public void setEvaluationDesc2(String evaluationDesc2) {
		this.evaluationDesc2 = evaluationDesc2;
	}

	public Double getEvaluationScore2() {
		return evaluationScore2;
	}

	public void setEvaluationScore2(Double evaluationScore2) {
		this.evaluationScore2 = evaluationScore2;
	}

	public String getEvaluationDesc3() {
		return evaluationDesc3;
	}

	public void setEvaluationDesc3(String evaluationDesc3) {
		this.evaluationDesc3 = evaluationDesc3;
	}

	public Double getEvaluationScore3() {
		return evaluationScore3;
	}

	public void setEvaluationScore3(Double evaluationScore3) {
		this.evaluationScore3 = evaluationScore3;
	}

	public String getEvaluationDesc4() {
		return evaluationDesc4;
	}

	public void setEvaluationDesc4(String evaluationDesc4) {
		this.evaluationDesc4 = evaluationDesc4;
	}

	public Double getEvaluationScore4() {
		return evaluationScore4;
	}

	public void setEvaluationScore4(Double evaluationScore4) {
		this.evaluationScore4 = evaluationScore4;
	}

	public String getEvaluationDesc5() {
		return evaluationDesc5;
	}

	public void setEvaluationDesc5(String evaluationDesc5) {
		this.evaluationDesc5 = evaluationDesc5;
	}

	public Double getEvaluationScore5() {
		return evaluationScore5;
	}

	public void setEvaluationScore5(Double evaluationScore5) {
		this.evaluationScore5 = evaluationScore5;
	}

	public String getEvaluationTotalDesc() {
		return evaluationTotalDesc;
	}

	public void setEvaluationTotalDesc(String evaluationTotalDesc) {
		this.evaluationTotalDesc = evaluationTotalDesc;
	}

	public Double getEvaluationTotalScore() {
		return evaluationTotalScore;
	}

	public void setEvaluationTotalScore(Double evaluationTotalScore) {
		this.evaluationTotalScore = evaluationTotalScore;
	}

	public String getEvaluatedBy() {
		return evaluatedBy;
	}

	public void setEvaluatedBy(String evaluatedBy) {
		this.evaluatedBy = evaluatedBy;
	}

	public Date getEvaluationTime() {
		return evaluationTime;
	}

	public void setEvaluationTime(Date evaluationTime) {
		this.evaluationTime = evaluationTime;
	}

	public Date getGmtCreateTime() {
		return gmtCreateTime;
	}

	public void setGmtCreateTime(Date gmtCreateTime) {
		this.gmtCreateTime = gmtCreateTime;
	}

	public Date getGmtUpdateTime() {
		return gmtUpdateTime;
	}

	public void setGmtUpdateTime(Date gmtUpdateTime) {
		this.gmtUpdateTime = gmtUpdateTime;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(String updatedBy) {
		this.updatedBy = updatedBy;
	}

	public boolean isDelete() {
		return isDelete;
	}

	public void setDelete(boolean isDelete) {
		this.isDelete = isDelete;
	}

	public Set<TPurchaseOrderItems> gettPurchaseOrderItems() {
		return tPurchaseOrderItems;
	}

	public void settPurchaseOrderItems(
			Set<TPurchaseOrderItems> tPurchaseOrderItems) {
		this.tPurchaseOrderItems = tPurchaseOrderItems;
	}

	public Set<TPurchaseOrderExecution> gettPurchaseOrderExecutions() {
		return tPurchaseOrderExecutions;
	}

	public void settPurchaseOrderExecutions(
			Set<TPurchaseOrderExecution> tPurchaseOrderExecutions) {
		this.tPurchaseOrderExecutions = tPurchaseOrderExecutions;
	}

	public Set<TPurchaseOrderPayment> gettPurchaseOrderPayment() {
		return tPurchaseOrderPayment;
	}

	public void settPurchaseOrderPayment(
			Set<TPurchaseOrderPayment> tPurchaseOrderPayment) {
		this.tPurchaseOrderPayment = tPurchaseOrderPayment;
	}

}
